package fschmidt.html;


public final class HtmlNode extends HtmlTag {
	public final Html children;

	public HtmlNode(HtmlTag tag,Html children) {
		super(tag);
		if( tag.isEmpty() )
			throw new RuntimeException();
		this.children = children;
	}

	@Override public String toString() {
		return super.toString() + children + "</" + getName() + ">";
	}

	@Override public boolean equals(Object obj) {
		if( !super.equals(obj) )
			return false;
		if( !(obj instanceof HtmlNode) )
			return false;
		HtmlNode node = (HtmlNode)obj;
		return children.equals(node.children);
	}

	void flattenTo(Html html) {
		html.add( new HtmlTag(this) );
		children.flattenTo(html);
		html.add( new HtmlTag( "/" + getName() ) );
	}
}
